#pragma once
#include <nice2d/widgets/abstractslider.h>
#include <nice2d/widgets/basicbutton.h>

class SliderStyle : public ControlStyle
{
    DECLARE_OBJECT(SliderStyle)
public:
    SliderStyle();

    float sliderButtonWidth = 9;
    float sliderButtonHeight = 24;
    sf::Color tickColor;
    std::shared_ptr<BasicButtonStyle> buttonStyle;
};

enum TickPlacement
{
    TickPlacement_None = 0,
    TickPlacement_Left,
    TickPlacement_Below,
    TickPlacement_Right,
    TickPlacement_Above,
    TickPlacement_Center
};

class Slider : public AbstractSlider
{
    DECLARE_OBJECT(Slider)
public:
    Slider(Orientation o = Orientation_H);
    ~Slider();
public:
    Orientation getOrientation()const;

    void setTickPlacement(TickPlacement place);
    TickPlacement getTickPlacement()const;

    void setTickFrequency(int frequency);
    int getTickFrequency() const;

    int getTrackLength();
protected:
    void onDrawControl(sf::RenderTarget &target, sf::RenderStates states) const override;

    void onMouseEnter()override;
    void onMouseExit()override;
    void onMousePressed(sf::Mouse::Button button)override;
    void onMouseReleased(sf::Mouse::Button button)override;
    void onMouseWheelScroll(float scroll)override;
    void onMouseMoved(int x,int y)override;

    void onPositionChanged() override;
    void onSizeChanged() override;
    void onStyleChanged()override;

    void onValueChanged() override;
    void adjust();
private:
    std::unique_ptr<class SliderData> data;
};
